<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>

<html>
<head> 
	<title>Videshop POS</title> 
	<link href="../css/style.css" rel="stylesheet" type="text/css">
</head>
<body>
	<f:view>
		<table border="0" cellpadding="0" cellspacing="10">
			<tr>
				<td colspan="2"><h1>Videoshop POS</h1></td>
			</tr>
			<tr>
				<td valign="top">
					<table border="0" cellpadding="0" cellspacing="0">
						<tr>
							<td>
								<!-- User section -->
								<f:subview id="userSection">
									<jsp:include page="user.jsp"/>
								</f:subview>
							</td>
						</tr>
						<tr>
							<td>
								<!-- Menu section -->
								<f:subview id="menuSection">
									<jsp:include page="menu.jsp"/>
								</f:subview>
							</td>
						</tr>
					</table>
				</td>
				<td valign="top" class="mainSection">
					<c:choose>
						<c:when test="${!empty userSection.staff}">
							<h2>Customers</h2>
							<h:form id="customerForm">
								<h:dataTable 	id="customerTable" 
												border="0" cellspacing="0" cellpadding="3"
												styleClass="dataTable"
												columnClasses="customerTableIdColumn,customerTableUserNameColumn,customerTableFirstNameColumn,customerTableLastNameColumn,customerTableActionColumn"
												value="#{customerSection.customers}"
												var="customer"
								>
									<h:column headerClass="customerTableIdColumn">
										<f:facet name="header">
											<h:commandLink action="#{customerSection.sortByCustomerId}">
												<f:verbatim escape="true">Customer Id</f:verbatim>
											</h:commandLink>
										</f:facet>
										<h:outputText value="#{customer.customerId}"/>
									</h:column>
									<h:column headerClass="customerTableUserNameColumn">
										<f:facet name="header">
											<h:commandLink action="#{customerSection.sortByUserName}">
												<f:verbatim escape="true">User Name</f:verbatim>
											</h:commandLink>
										</f:facet>
										<h:outputText value="#{customer.userName}"/>
									</h:column>
									<h:column headerClass="customerTableFirstNameColumn">
										<f:facet name="header">
											<h:commandLink action="#{customerSection.sortByFirstName}">
												<f:verbatim escape="true">First Name</f:verbatim>
											</h:commandLink>
										</f:facet>
										<h:outputText value="#{customer.firstName}"/>
									</h:column>
									<h:column headerClass="customerTableLastNameColumn">
										<f:facet name="header">
											<h:commandLink action="#{customerSection.sortByLastName}">
												<f:verbatim escape="true">Last Name</f:verbatim>
											</h:commandLink>
										</f:facet>
										<h:outputText value="#{customer.lastName}"/>
									</h:column>
									<h:column headerClass="customerTableActionColumn">
										<f:facet name="header">
											<f:verbatim escape="true">Action</f:verbatim>
										</f:facet>
										<h:commandLink styleClass="button" action="#{customerSection.edit}">
											<f:verbatim escape="true">Edit</f:verbatim>
										</h:commandLink>
										<h:commandLink styleClass="button" action="#{customerSection.view}">
											<f:verbatim escape="true">View</f:verbatim>
										</h:commandLink>
										<h:commandLink styleClass="button" action="#{customerSection.delete}">
											<f:verbatim escape="true">Delete</f:verbatim>
										</h:commandLink>
									</h:column>
								</h:dataTable>
								<h:commandLink styleClass="button" action="#{customerSection.add}">
									<f:verbatim escape="true">Add</f:verbatim>
								</h:commandLink>
							</h:form>
						</c:when>
						<c:otherwise>
							Please login
						</c:otherwise>
					</c:choose>
				</td>
			</tr>
		</table>
	</f:view>
</html>